package b1.mobile.blackberry.ui.component;

import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.LabelField;

public class ColoredLabelField extends LabelField {
	int foregroundColor;
	int foregroundColorFocus;

	public ColoredLabelField(String label, int foregroundColor, long style) {
		this(label, foregroundColor, foregroundColor, style);
	}

	public ColoredLabelField(String label, int foregroundColor, int foregroundColorFocus, long style) {
		super(label, style);
		this.foregroundColor = foregroundColor;
		this.foregroundColorFocus = foregroundColorFocus;
	}

	protected void paint(Graphics g) {
		int oldColour = g.getColor();
		try {
			g.setColor(g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS) ? foregroundColorFocus
					: foregroundColor);
			super.paint(g);
		} finally {
			g.setColor(oldColour);
		}
	}
}
